package com.qf.util;

import com.qf.dao.TaskDao;
import com.qf.dao.impl.TaskDaoImpl;
import com.qf.entity.Task;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import java.util.Date;
import java.util.List;

/**
 * 2019/10/8
 * Administrator
 * quartz1008
 * 面向对象面向君  不负代码不负卿
 */
//步骤1:创建Job类。job类=工作类，用来定义需要程序调取的做的事情
public class MyJob implements Job {
    //需要执行的任务
    public void execute(JobExecutionContext jec) throws JobExecutionException {
        TaskDao dao=new TaskDaoImpl();
        JobDataMap dataMap = jec.getJobDetail().getJobDataMap();
        List<Task> taskList = dao.findTaskByName((String) dataMap.get("uname"));
        for (Task task : taskList) {
            System.out.println(new Date()+","+task);
        }
    }
}
